from app import db
from werkzeug.security import check_password_hash,generate_password_hash

class User(db.Model):
    __tablename__="user"
    id= db.Column(db.Integer,primary_key=True,autoincrement=True)
    name = db.Column(db.Integer)
    pwd = db.Column(db.String(200))
    r_id =db.Column(db.Integer,db.ForeignKey("role.id"))
#密码加密
    @property
    def password(self):
        return self.pwd
    @password.setter
    def password(self,t_pwd):
        self.pwd=generate_password_hash(t_pwd)
    def rz_password(self,t_pwd):
        return check_password_hash(self.pwd,t_pwd)
class Role(db.Model):
    __tablename__="role"
    id=db.Column(db.Integer,primary_key=True,autoincrement=True)
    pwname=db.Column(db.String(50))


